package com.origin.src.dep;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportAware;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Indexed;

@Component
//@Indexed
@Import(DepA.DepAb.class)//因为实现了ImportSelector接口，这句是无用的？
public class DepA implements ImportAware, ImportSelector {
    @Autowired
    DepB depB;

    @Override
    public void setImportMetadata(AnnotationMetadata importMetadata) {
        System.out.println(importMetadata.getAnnotationTypes());
    }

    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        return new String[]{"com.origin.src.dep.DepA$DepAa"};
    }

    public static void main(String[] args) throws ClassNotFoundException {
        Class<DepAa> clz = (Class<DepAa>) DepA.class.getClassLoader().loadClass("com.origin.src.dep.DepA$DepAa");
        System.out.println(clz.getName());
    }

    public static class DepAa {

//        public DepAa(DepApplicationContext.DepBeanC c, DepApplicationContext.DepBeanD d) {
//
//        }


    }

    public static class DepAb {

    }
}
